package org.example.service.controller;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.example.service.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {

    @Value("${server.port}")
    private String serverPort;
    @Autowired
    private OrderService orderService;
    @GetMapping("/getOrder")
    public String getOrder()
    {
        System.out.println("Come here to get Order....===");
        return "oreder service from:"+serverPort;
    }
    @GetMapping("/orderCount")
    public String orderCount(@RequestParam int count, HttpServletRequest request, HttpServletResponse response)
    {
        log.info("serverPort:"+serverPort);
        if (count==500||count==404){
            response.setStatus(count);
        }
        return "10/count:"+10/count+"from:"+serverPort;

    }

}
